
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/14/2012 17:38:18
-- Generated from EDMX file: C:\DropBox\Dropbox\Work\Freelance\Src\freelance\Freelance\Freejobber.Core\Data\db_Freelance.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [db_Freelance];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_tbl_UserProfile_tbl_Users1]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[tbl_UserProfile] DROP CONSTRAINT [FK_tbl_UserProfile_tbl_Users1];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[sysdiagrams]', 'U') IS NOT NULL
    DROP TABLE [dbo].[sysdiagrams];
GO
IF OBJECT_ID(N'[dbo].[tbl_UserProfile]', 'U') IS NOT NULL
    DROP TABLE [dbo].[tbl_UserProfile];
GO
IF OBJECT_ID(N'[dbo].[tbl_Users]', 'U') IS NOT NULL
    DROP TABLE [dbo].[tbl_Users];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'sysdiagrams'
CREATE TABLE [dbo].[sysdiagrams] (
    [name] nvarchar(128)  NOT NULL,
    [principal_id] int  NOT NULL,
    [diagram_id] int IDENTITY(1,1) NOT NULL,
    [version] int  NULL,
    [definition] varbinary(max)  NULL
);
GO

-- Creating table 'tbl_UserProfile'
CREATE TABLE [dbo].[tbl_UserProfile] (
    [Id] int  NOT NULL,
    [UserId] int  NOT NULL,
    [EmailAdress] nvarchar(128)  NOT NULL,
    [Created] datetime  NULL
);
GO

-- Creating table 'tbl_Users'
CREATE TABLE [dbo].[tbl_Users] (
    [Id] int  NOT NULL,
    [LoginName] nvarchar(128)  NOT NULL,
    [Password] nvarchar(128)  NOT NULL,
    [AdminLevel] tinyint  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [diagram_id] in table 'sysdiagrams'
ALTER TABLE [dbo].[sysdiagrams]
ADD CONSTRAINT [PK_sysdiagrams]
    PRIMARY KEY CLUSTERED ([diagram_id] ASC);
GO

-- Creating primary key on [UserId] in table 'tbl_UserProfile'
ALTER TABLE [dbo].[tbl_UserProfile]
ADD CONSTRAINT [PK_tbl_UserProfile]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- Creating primary key on [Id] in table 'tbl_Users'
ALTER TABLE [dbo].[tbl_Users]
ADD CONSTRAINT [PK_tbl_Users]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [UserId] in table 'tbl_UserProfile'
ALTER TABLE [dbo].[tbl_UserProfile]
ADD CONSTRAINT [FK_tbl_UserProfile_tbl_Users1]
    FOREIGN KEY ([UserId])
    REFERENCES [dbo].[tbl_Users]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------